using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Gadgets.Common
{
    public partial class AccountNo : UserControl
    {
        public AccountNo()
        {
            InitializeComponent();
        }

        public string Value
        {
            get
            {
                if (txtAccountNo.Text ==  string.Empty)
                    return string.Empty;
                else
                    return txtCodeIssuer.Text + txtAccountNo.Text;
            }
            set
            {
                if (value.Length == 10)
                {
                    txtCodeIssuer.Text = value.Substring(0, 4);
                    txtAccountNo.Text = value.Substring(4, 6);
                }
            }
        }
        public string Text
        {
            get
            {
                if (txtAccountNo.Text == string.Empty)
                    return string.Empty;
                else
                    return txtCodeIssuer.Text + txtAccountNo.Text;
            }
            set
            {
                if (value.Length == 10)
                {
                    txtCodeIssuer.Text = value.Substring(0, 4);
                    txtAccountNo.Text = value.Substring(4, 6);
                }
            }
        }

        private void txtAccountNo_KeyPress(object sender, KeyPressEventArgs e)
        {
            this.OnKeyPress(e);
        }

        private void AccountNo_Load(object sender, EventArgs e)
        {
            txtCodeIssuer.Text = DeclareLibrary.MEMBER_CODE + DeclareLibrary.PCFLAG_DEFAULT;
            txtAccountNo.Focus();
        }

        private void txtAccountNo_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F4)
            {
                Common.InvestorComfirmation obj = new Common.InvestorComfirmation();
                obj.account_no = txtCodeIssuer.Text + txtAccountNo.Text;
                obj.ShowDialog();
            }
        } 
    }
}
